using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using Acms.SqlDal;

namespace Acms.Bll
{
    public class UserPostVoteAverage : BaseItem
    {
        protected UserPostVoteAverage() : base() { }
        protected UserPostVoteAverage(Hashtable table) : base(table) { }
        protected UserPostVoteAverage(Hashtable table, List<UserPostVoteAverage> collection) : base(table, collection) { }

        public static UserPostVoteAverage CreateInstance()
        {
            return new UserPostVoteAverage();
        }

        private static UserPostVoteAverage Get(Hashtable table)
        {
            if (table != null)
            {
                return new UserPostVoteAverage(table);
            }
            else
            {
                return null;
            }
        }

        private static List<UserPostVoteAverage> Get(Hashtable[] tables)
        {
            if (tables != null)
            {
                List<UserPostVoteAverage> tmp = new List<UserPostVoteAverage>();
                foreach (Hashtable table in tables)
                {
                    tmp.Add(new UserPostVoteAverage(table, tmp));
                }
                return tmp;
            }
            else
            {
                return null;
            }
        }

        public static UserPostVoteAverage GetByPostGuid(Guid postGuid)
        {
            UserPostVoteAverageDal dal = new UserPostVoteAverageDal();
            return Get(dal.GetByPostGuid(postGuid));
        }

        public static List<UserPostVoteAverage> GetAllBySiteId(int siteId)
        {
            UserPostVoteAverageDal dal = new UserPostVoteAverageDal();
            return Get(dal.GetAllBySiteId(siteId));
        }

        protected override void Load(Hashtable table)
        {
            postGuid = (Guid)table[UserPostVoteAverageDal.Fields.PostGuid];
            /*siteId = (int)table[UserPostVoteAverageDal.Fields.SiteId];
            postName = (string)table[UserPostVoteAverageDal.Fields.PostName];
            postDisplayName = (string)table[UserPostVoteAverageDal.Fields.PostDisplayName];
            parentId = (int)table[UserPostVoteAverageDal.Fields.ParentId];
            parentPath = (string)table[UserPostVoteAverageDal.Fields.ParentPath];*/
            average = (decimal)table[UserPostVoteAverageDal.Fields.Average];
            total = (int)table[UserPostVoteAverageDal.Fields.Total];
        }

        private Guid postGuid;
        public Guid PostGuid
        {
            get { return postGuid; }
        }

        /*private int siteId;
        public int SiteId
        {
            get { return siteId; }
        }

        private string postName;
        public string PostName
        {
            get { return postName; }
        }

        private string postDisplayName;
        public string PostDisplayName
        {
            get { return postDisplayName; }
        }

        private int parentId;
        public int ParentId
        {
            get { return parentId; }
        }

        private string parentPath;
        public string ParentPath
        {
            get { return parentPath; }
        }*/

        private decimal average;
        public decimal Average
        {
            get { return average; }
        }

        private int total;
        public int Total
        {
            get { return total; }
        }


        protected override Acms.SqlDal.Base CreateDal()
        {
            return new UserPostVoteAverageDal();
        }
    }
}
